package com.eloisa.gls.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eloisa.gls.dao.ICheckInDao;
import com.eloisa.gls.dao.IUserDao;
import com.eloisa.gls.domain.CheckIn;
import com.eloisa.gls.domain.User;

@Service
public class UserContentService implements IUserContentService{
	@Autowired
	private IUserDao userDao;
	@Autowired
	private ICheckInDao checkInDao;
	
	
	public User getUser(String account, String uuid) {
		User user = userDao.getUser(account, uuid);
		return user;
	}
	
	public User getUser(Integer id) {
		User user = userDao.findById(id);
		return user;
	}

	public void createUser(User user) {
		userDao.create(user);
	}

	public void updateUser(User user) {
		User old = getUser(user.getId());
		old.setAccount(user.getAccount());
		old.setUuid(user.getUuid());
		old.setOpenId(user.getOpenId());
		old.setName(user.getName());
		old.setIsProfessor(user.getIsProfessor());
		userDao.update(old);
	}

	public void deleteUser(Integer id) {
		User old = getUser(id);
		userDao.delete(old);
	}
	
	
	
	
	

	
	public CheckIn getCheckIn(Integer id) {
		CheckIn checkIn = checkInDao.findById(id);
		return checkIn;
	}

	public void createCheckIn(CheckIn checkIn) {
		checkInDao.create(checkIn);
	}

	public void updateCheckIn(CheckIn checkIn) {
		CheckIn old = getCheckIn(checkIn.getId());
		old.setUserId(checkIn.getUserId());
		old.setLessonId(checkIn.getLessonId());
		old.setCheckInTime(checkIn.getCheckInTime());
		checkInDao.update(old);
	}

	public void deleteCheckIn(Integer id) {
		CheckIn old = getCheckIn(id);
		checkInDao.delete(old);
	}
	
	
	
	
	
	

}
